package com.mysoftbase.base.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * @Author: JohnCoding
 * @Description:
 * @date: 2019/12/19 15:10
 */
@Configuration
@MapperScan("com.mysoft.dao.dao")
public class MyBatisPlusConfig {

    /**
     * 配置MybatisPlus 物理分页插件
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        return paginationInterceptor;
    }

    /**
     * 配置MybatisPlus SQL执行插件
     * @return
     */
    @Bean
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor =  new PerformanceInterceptor();
        performanceInterceptor.setFormat(true);//格式化语句
        //performanceInterceptor.setMaxTime(5);//执行时间超过多少秒会抛出异常
        return  performanceInterceptor;
    }
}
